package com.quartz.config;

import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.quartz.CronTriggerFactoryBean;
import org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

/**
 * @描述:
 * @类名:
 * @作者: yangshuang
 * @创建时间: 2017/8/16 20:38
 * @版本: v1.0
 */
//@Configuration
public class ScheduleConfiguration {
   /* //1.jobDetail

    *//**
     * 定义jobDetail
     *
     * @param task
     * @return
     *//*
    @Bean
    public MethodInvokingJobDetailFactoryBean detailFactoryBean(ScheduledTask task) {
        MethodInvokingJobDetailFactoryBean bean = new MethodInvokingJobDetailFactoryBean();
        //设置对应的job对象
        bean.setTargetObject(task);
        //设置对应的方法名
        bean.setTargetMethod("excute");
        return bean;
    }

    *//**
     * 定义trigger
     *
     * @return
     *//*
    @Bean
    public CronTriggerFactoryBean cronTriggerFactoryBean(MethodInvokingJobDetailFactoryBean jobDetail) {
        CronTriggerFactoryBean trigger = new CronTriggerFactoryBean();
        trigger.setJobDetail(jobDetail.getObject());
        trigger.setCronExpression("0/5 * * * * ?");//没五秒实行一次
        return trigger;
    }

    *//**
     * 定义schedule
     * @param cronTriggerFactoryBean
     * @return
     *//*
    @Bean
    public SchedulerFactoryBean schedulerFactoryBean(CronTriggerFactoryBean cronTriggerFactoryBean){
        SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
        schedulerFactoryBean.setTriggers(cronTriggerFactoryBean.getObject());
        return schedulerFactoryBean;
    }*/
}
